package com.itheima.d3_inner_class3;

/*
    1 匿名内部类在开发中的使用场景
        通常作为一个参数传输给方法。

 */
public class Test2 {
    public static void main(String[] args) {
        Swimming s = new SwimmingImpl();
        show(s);
        show(new Swimming() {
            @Override
            public void swim() {
                System.out.println("我学会游泳了");
            }
        });
    }

    public static void show(Swimming s) {
        System.out.println("计时开始");
        s.swim();
        System.out.println("计时结束");
    }
}

interface Swimming {
    void swim();
}

class SwimmingImpl implements Swimming {

    @Override
    public void swim() {
        System.out.println("我会游泳");
    }
}